package com.kingwang.demo.springsecuritytokendemo.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * JSON转换工具类
 *
 * @author King
 */
public class JsonConvert {
    private static ObjectMapper objectMapper;

    static {
        objectMapper = new ObjectMapper();
    }

    private JsonConvert() {
        throw new IllegalStateException("Utility class");
    }

    public static String serializeObject(Object obj) throws JsonProcessingException {
        return objectMapper.writeValueAsString(obj);
    }
}
